<template>
  <div>
    <el-dialog
      :title="title"
      :close-on-click-modal="false"
      v-dialogDrag
      :visible.sync="visible"
    >
      <el-steps :active="active" align-center>
        <el-step title="基本信息"></el-step>
        <el-step title="地址信息"></el-step>
        <el-step title="工商信息"></el-step>
      </el-steps>
      <br />
      <div v-show="active == 1" style="margin-top: 20px">
        <el-form
          :model="inputForm"
          ref="inputForm"
          v-loading="loading"
          :class="method === 'view' ? 'readonly' : ''"
          :disabled="method === 'view'"
          label-width="120px"
        >
          <el-row :gutter="15">
            <el-col :span="12">
              <el-form-item
                label="用户ID"
                prop="user.id"
                :rules="[
                  {
                    required: true,
                    message: '用户ID不能为空',
                    trigger: 'blur',
                  },
                ]"
              >
                <GridSelect
                  title="选择用户ID"
                  labelName="phone"
                  labelValue="id"
                  :value="inputForm.user.id"
                  :limit="1"
                  @getValue="
                    (value) => {
                      inputForm.user.id = value;
                    }
                  "
                  :columns="[
                    {
                      prop: 'id',
                      label: '主键',
                    },
                    {
                      prop: 'phone',
                      label: '手机号(账号唯一)',
                    },
                    {
                      prop: 'nikeName',
                      label: '昵称',
                    },
                  ]"
                  :searchs="[
                    {
                      prop: 'phone',
                      label: '手机号(账号唯一)',
                    },
                    {
                      prop: 'nikeName',
                      label: '昵称',
                    },
                  ]"
                  dataListUrl="/userinfo/tUserInfo/list"
                  entityBeanName="tUserInfo"
                  queryEntityUrl="/userinfo/tUserInfo/queryById"
                >
                </GridSelect>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item
                label="企业全称"
                prop="enterpriseFullName"
                :rules="[
                  {
                    required: true,
                    message: '企业全称不能为空',
                    trigger: 'blur',
                  },
                ]"
              >
                <el-input
                  v-model="inputForm.enterpriseFullName"
                  placeholder="请填写企业全称"
                ></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item
                label="统一社会信用代码"
                prop="unifiedSocialCreditCode"
                :rules="[
                  {
                    required: true,
                    message: '统一社会信用代码不能为空',
                    trigger: 'blur',
                  },
                ]"
              >
                <el-input
                  v-model="inputForm.unifiedSocialCreditCode"
                  placeholder="请填写统一社会信用代码"
                ></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item
                label="公司规模"
                prop="companySize"
                :rules="[
                  {
                    required: true,
                    message: '公司规模不能为空',
                    trigger: 'blur',
                  },
                ]"
              >
                <el-input
                  v-model="inputForm.companySize"
                  placeholder="请填写公司规模"
                ></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item
                label="法人姓名"
                prop="legalPersonName"
                :rules="[
                  {
                    required: true,
                    message: '法人姓名不能为空',
                    trigger: 'blur',
                  },
                ]"
              >
                <el-input
                  v-model="inputForm.legalPersonName"
                  placeholder="请填写法人姓名"
                ></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item
                label="经办人姓名"
                prop="attentionLine"
                :rules="[
                  {
                    required: true,
                    message: '经办人姓名不能为空',
                    trigger: 'blur',
                  },
                ]"
              >
                <el-input
                  v-model="inputForm.attentionLine"
                  placeholder="请填写经办人姓名"
                ></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item
                label="经办人电话"
                prop="operatorsTelephone"
                :rules="[
                  {
                    required: true,
                    message: '经办人电话不能为空',
                    trigger: 'blur',
                  },
                ]"
              >
                <el-input
                  v-model="inputForm.operatorsTelephone"
                  placeholder="请填写经办人电话"
                ></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item
                label="所属行业"
                prop="affiliationIndustry"
                :rules="[
                  {
                    required: true,
                    message: '所属行业不能为空',
                    trigger: 'blur',
                  },
                ]"
              >
                <el-input
                  v-model="inputForm.affiliationIndustry"
                  placeholder="请填写所属行业"
                ></el-input>
              </el-form-item>
            </el-col>
            <!-- <el-col :span="12">
              <el-form-item
                label="营业执照"
                prop="businessLicense"
                :rules="[
                  {
                    required: true,
                    message: '营业执照不能为空',
                    trigger: 'blur',
                  },
                ]"
              >
                <el-input
                  v-model="inputForm.businessLicense"
                  placeholder="请填写营业执照"
                ></el-input>
              </el-form-item>
            </el-col> -->
            <el-col :span="24">
              <el-form-item
                label="营业执照"
                prop="businessLicense"
                :rules="[
                  {
                    required: true,
                    message: '营业执照不能为空',
                    trigger: 'blur',
                  },
                ]"
              >
                <el-upload
                  ref="businessLicense"
                  v-if="visible"
                  list-type="picture-card"
                  :action="`${this.$http.BASE_URL}/sys/file/webupload/upload?uploadPath=/p_enterprisecertification/pEnterpriseCertification`"
                  :headers="{ token: $cookie.get('token') }"
                  :on-preview="
                    (file, fileList) => {
                      showImg(inputForm.businessLicense);
                    }
                  "
                  :on-success="
                    (response, file, fileList) => {
                      inputForm.businessLicense = fileList
                        .map(
                          (item) =>
                            (item.response && item.response.url) || item.url
                        )
                        .join('|');
                    }
                  "
                  :on-remove="
                    (file, fileList) => {
                      $http
                        .post(
                          `/sys/file/webupload/deleteByUrl?url=${
                            (file.response && file.response.url) || file.url
                          }`
                        )
                        .then(({ data }) => {
                          $message.success(data.msg);
                        });
                      inputForm.businessLicense = fileList
                        .map((item) => item.url)
                        .join('|');
                    }
                  "
                  :before-remove="
                    (file, fileList) => {
                      return $confirm(`确定移除 ${file.name}？`);
                    }
                  "
                  multiple
                  :limit="1"
                  :on-exceed="
                    (files, fileList) => {
                      $message.warning(
                        `当前限制选择 1 个文件，本次选择了 ${
                          files.length
                        } 个文件，共选择了 ${
                          files.length + fileList.length
                        } 个文件`
                      );
                    }
                  "
                  :file-list="businessLicenseArra"
                >
                  <i class="el-icon-plus"></i>
                </el-upload>
              </el-form-item>
            </el-col>
            <el-col :span="24">
              <el-form-item
                label="法人身份证（人像面）"
                prop="legalPersonIdCardPortrait"
                :rules="[
                  {
                    required: true,
                    message: '法人身份证（人像面）不能为空',
                    trigger: 'blur',
                  },
                ]"
              >
                <el-upload
                  ref="legalPersonIdCardPortrait"
                  v-if="visible"
                  list-type="picture-card"
                  :action="`${this.$http.BASE_URL}/sys/file/webupload/upload?uploadPath=/p_enterprisecertification/pEnterpriseCertification`"
                  :headers="{ token: $cookie.get('token') }"
                  :on-preview="
                    (file, fileList) => {
                      showImg(inputForm.legalPersonIdCardPortrait);
                    }
                  "
                  :on-success="
                    (response, file, fileList) => {
                      inputForm.legalPersonIdCardPortrait = fileList
                        .map(
                          (item) =>
                            (item.response && item.response.url) || item.url
                        )
                        .join('|');
                    }
                  "
                  :on-remove="
                    (file, fileList) => {
                      $http
                        .post(
                          `/sys/file/webupload/deleteByUrl?url=${
                            (file.response && file.response.url) || file.url
                          }`
                        )
                        .then(({ data }) => {
                          $message.success(data.msg);
                        });
                      inputForm.legalPersonIdCardPortrait = fileList
                        .map((item) => item.url)
                        .join('|');
                    }
                  "
                  :before-remove="
                    (file, fileList) => {
                      return $confirm(`确定移除 ${file.name}？`);
                    }
                  "
                  multiple
                  :limit="1"
                  :on-exceed="
                    (files, fileList) => {
                      $message.warning(
                        `当前限制选择 1 个文件，本次选择了 ${
                          files.length
                        } 个文件，共选择了 ${
                          files.length + fileList.length
                        } 个文件`
                      );
                    }
                  "
                  :file-list="legalPersonIdCardPortraitArra"
                >
                  <i class="el-icon-plus"></i>
                </el-upload>
              </el-form-item>
            </el-col>
            <el-col :span="24">
              <el-form-item
                label="法人身份证（国徽面）"
                prop="legalPersonIdCardNationalEmblemFace"
                :rules="[
                  {
                    required: true,
                    message: '法人身份证（国徽面）不能为空',
                    trigger: 'blur',
                  },
                ]"
              >
                <el-upload
                  ref="legalPersonIdCardNationalEmblemFace"
                  v-if="visible"
                  list-type="picture-card"
                  :action="`${this.$http.BASE_URL}/sys/file/webupload/upload?uploadPath=/p_enterprisecertification/pEnterpriseCertification`"
                  :headers="{ token: $cookie.get('token') }"
                  :on-preview="
                    (file, fileList) => {
                      showImg(inputForm.legalPersonIdCardNationalEmblemFace);
                    }
                  "
                  :on-success="
                    (response, file, fileList) => {
                      inputForm.legalPersonIdCardNationalEmblemFace = fileList
                        .map(
                          (item) =>
                            (item.response && item.response.url) || item.url
                        )
                        .join('|');
                    }
                  "
                  :on-remove="
                    (file, fileList) => {
                      $http
                        .post(
                          `/sys/file/webupload/deleteByUrl?url=${
                            (file.response && file.response.url) || file.url
                          }`
                        )
                        .then(({ data }) => {
                          $message.success(data.msg);
                        });
                      inputForm.legalPersonIdCardNationalEmblemFace = fileList
                        .map((item) => item.url)
                        .join('|');
                    }
                  "
                  :before-remove="
                    (file, fileList) => {
                      return $confirm(`确定移除 ${file.name}？`);
                    }
                  "
                  multiple
                  :limit="1"
                  :on-exceed="
                    (files, fileList) => {
                      $message.warning(
                        `当前限制选择 1 个文件，本次选择了 ${
                          files.length
                        } 个文件，共选择了 ${
                          files.length + fileList.length
                        } 个文件`
                      );
                    }
                  "
                  :file-list="legalPersonIdCardNationalEmblemFaceArra"
                >
                  <i class="el-icon-plus"></i>
                </el-upload>
              </el-form-item>
            </el-col>
            <el-col :span="24">
              <el-form-item
                label="经办人身份证（人像面）"
                prop="handledByIdCardPortrait"
                :rules="[
                  {
                    required: true,
                    message: '经办人身份证（人像面）不能为空',
                    trigger: 'blur',
                  },
                ]"
              >
                <el-upload
                  ref="handledByIdCardPortrait"
                  v-if="visible"
                  list-type="picture-card"
                  :action="`${this.$http.BASE_URL}/sys/file/webupload/upload?uploadPath=/p_enterprisecertification/pEnterpriseCertification`"
                  :headers="{ token: $cookie.get('token') }"
                  :on-preview="
                    (file, fileList) => {
                      showImg(inputForm.handledByIdCardPortrait);
                    }
                  "
                  :on-success="
                    (response, file, fileList) => {
                      inputForm.handledByIdCardPortrait = fileList
                        .map(
                          (item) =>
                            (item.response && item.response.url) || item.url
                        )
                        .join('|');
                    }
                  "
                  :on-remove="
                    (file, fileList) => {
                      $http
                        .post(
                          `/sys/file/webupload/deleteByUrl?url=${
                            (file.response && file.response.url) || file.url
                          }`
                        )
                        .then(({ data }) => {
                          $message.success(data.msg);
                        });
                      inputForm.handledByIdCardPortrait = fileList
                        .map((item) => item.url)
                        .join('|');
                    }
                  "
                  :before-remove="
                    (file, fileList) => {
                      return $confirm(`确定移除 ${file.name}？`);
                    }
                  "
                  multiple
                  :limit="1"
                  :on-exceed="
                    (files, fileList) => {
                      $message.warning(
                        `当前限制选择 1 个文件，本次选择了 ${
                          files.length
                        } 个文件，共选择了 ${
                          files.length + fileList.length
                        } 个文件`
                      );
                    }
                  "
                  :file-list="handledByIdCardPortraitArra"
                >
                  <i class="el-icon-plus"></i>
                </el-upload>
              </el-form-item>
            </el-col>
            <el-col :span="24">
              <el-form-item
                label="经办人身份证（国徽面）"
                prop="handledByIdCardNationalEmblemFace"
                :rules="[
                  {
                    required: true,
                    message: '经办人身份证（国徽面）不能为空',
                    trigger: 'blur',
                  },
                ]"
              >
                <el-upload
                  ref="handledByIdCardNationalEmblemFace"
                  v-if="visible"
                  list-type="picture-card"
                  :action="`${this.$http.BASE_URL}/sys/file/webupload/upload?uploadPath=/p_enterprisecertification/pEnterpriseCertification`"
                  :headers="{ token: $cookie.get('token') }"
                  :on-preview="
                    (file, fileList) => {
                      showImg(inputForm.handledByIdCardNationalEmblemFace);
                    }
                  "
                  :on-success="
                    (response, file, fileList) => {
                      inputForm.handledByIdCardNationalEmblemFace = fileList
                        .map(
                          (item) =>
                            (item.response && item.response.url) || item.url
                        )
                        .join('|');
                    }
                  "
                  :on-remove="
                    (file, fileList) => {
                      $http
                        .post(
                          `/sys/file/webupload/deleteByUrl?url=${
                            (file.response && file.response.url) || file.url
                          }`
                        )
                        .then(({ data }) => {
                          $message.success(data.msg);
                        });
                      inputForm.handledByIdCardNationalEmblemFace = fileList
                        .map((item) => item.url)
                        .join('|');
                    }
                  "
                  :before-remove="
                    (file, fileList) => {
                      return $confirm(`确定移除 ${file.name}？`);
                    }
                  "
                  multiple
                  :limit="1"
                  :on-exceed="
                    (files, fileList) => {
                      $message.warning(
                        `当前限制选择 1 个文件，本次选择了 ${
                          files.length
                        } 个文件，共选择了 ${
                          files.length + fileList.length
                        } 个文件`
                      );
                    }
                  "
                  :file-list="handledByIdCardNationalEmblemFaceArra"
                >
                  <i class="el-icon-plus"></i>
                </el-upload>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item
                label="审核状态"
                prop="auditStatus"
                :rules="[
                  {
                    required: true,
                    message: '审核状态不能为空',
                    trigger: 'blur',
                  },
                ]"
              >
                <el-select
                  v-model="inputForm.auditStatus"
                  placeholder="请选择审核状态"
                  style="width: 100%"
                >
                  <el-option label="待审核" value="0"></el-option>
                  <el-option label="已通过" value="1"></el-option>
                  <el-option label="已拒绝" value="2"></el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="审核时间" prop="auditTime" :rules="[]">
                <el-date-picker
                  style="width: 100%"
                  v-model="inputForm.auditTime"
                  type="datetime"
                  value-format="yyyy-MM-dd HH:mm:ss"
                  placeholder="选择日期时间"
                >
                </el-date-picker>
              </el-form-item>
            </el-col>
            <el-col :span="24">
              <el-form-item label="拒绝原因" prop="reasonRejection" :rules="[]">
                <el-input
                  type="textarea"
                  v-model="inputForm.reasonRejection"
                  placeholder="请填写拒绝原因"
                ></el-input>
              </el-form-item>
            </el-col>

            <el-col :span="24">
              <el-form-item label="备注信息" prop="remarks" :rules="[]">
                <el-input
                  type="textarea"
                  v-model="inputForm.remarks"
                  placeholder="请填写备注信息"
                ></el-input>
              </el-form-item>
            </el-col>
          </el-row>
        </el-form>
      </div>
      <div v-show="active == 2" style="margin-top: 20px">
        <el-form
          :model="inputForm"
          ref="inputForm"
          v-loading="loading"
          :class="method === 'view' ? 'readonly' : ''"
          :disabled="method === 'view'"
          label-width="120px"
        >
          <el-col :span="12">
            <el-form-item label="办公区域" prop="officeArea" :rules="[]">
              <el-select
                v-model="inputForm.officeArea"
                placeholder="请选择类型"
                size="small"
                style="width: 100%"
              >
                <el-option
                  v-for="item in valueList"
                  :key="item.valueName"
                  :label="item.valueName"
                  :value="item.valueName"
                >
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>

          <el-col :span="24">
            <el-form-item label="办公地址" prop="officeAddress" :rules="[]">
              <el-input
                v-model="inputForm.officeAddress"
                ref="handleinput"
                id="handleinput"
                placeholder="请填写办公地址"
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="纬度" prop="latitude" :rules="[]">
              <el-input
                v-model="inputForm.latitude"
                disabled
                placeholder="请填写纬度"
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="经度" prop="longitude" :rules="[]">
              <el-input
                v-model="inputForm.longitude"
                disabled
                placeholder="请填写经度"
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col>
            <el-form-item label="地图" prop="">
              <div ref="container" id="containepic"></div>
            </el-form-item>
          </el-col>
        </el-form>
      </div>
      <div v-show="active == 3" style="margin-top: 20px">
        <el-form
          :model="inputForm2"
          ref="inputForm2"
          v-loading="loading"
          :class="method === 'view' ? 'readonly' : ''"
          :disabled="method === 'view'"
          label-width="120px"
        >
          <el-row :gutter="15">
            <!-- <el-col :span="12">
              <el-form-item
                label="企业认证信息ID"
                prop="enterpriseCertification.id"
                :rules="[]"
              >
                <GridSelect
                  title="选择企业认证信息ID"
                  labelName="enterpriseFullName"
                  labelValue="id"
                  :value="inputForm.enterpriseCertification.id"
                  :limit="1"
                  @getValue="
                    (value) => {
                      inputForm.enterpriseCertification.id = value;
                    }
                  "
                  :columns="[
                    {
                      prop: 'id',
                      label: '主键',
                    },
                    {
                      prop: 'enterpriseFullName',
                      label: '企业全称',
                    },
                    {
                      prop: 'unifiedSocialCreditCode',
                      label: '统一社会信用代码',
                    },
                    {
                      prop: 'officeArea',
                      label: '办公区域',
                    },
                    {
                      prop: 'officeAddress',
                      label: '办公地址',
                    },
                  ]"
                  :searchs="[
                    {
                      prop: 'enterpriseFullName',
                      label: '企业全称',
                    },
                    {
                      prop: 'unifiedSocialCreditCode',
                      label: '统一社会信用代码',
                    },
                    {
                      prop: 'officeArea',
                      label: '办公区域',
                    },
                    {
                      prop: 'officeAddress',
                      label: '办公地址',
                    },
                  ]"
                  dataListUrl="/p_enterprisecertification/pEnterpriseCertification/list"
                  entityBeanName="pEnterpriseCertification"
                  queryEntityUrl="/p_enterprisecertification/pEnterpriseCertification/queryById"
                >
                </GridSelect>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="内部KeyNo" prop="keyNo" :rules="[]">
                <el-input
                  v-model="inputForm.keyNo"
                  placeholder="请填写内部KeyNo"
                ></el-input>
              </el-form-item>
            </el-col> -->
            <el-col :span="24">
              <el-form-item label="企查查信息" prop="remarks" :rules="[]">
                <el-input
                  type="textarea"
                  v-model="inputForm2.remarks"
                ></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="企业名称" prop="name" :rules="[]">
                <el-input
                  v-model="inputForm2.name"
                  placeholder="请填写企业名称"
                ></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="工商注册号" prop="no" :rules="[]">
                <el-input
                  v-model="inputForm2.no"
                  placeholder="请填写工商注册号"
                ></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="登记机关" prop="belongOrg" :rules="[]">
                <el-input
                  v-model="inputForm2.belongOrg"
                  placeholder="请填写登记机关"
                ></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="法定代表人ID" prop="operId" :rules="[]">
                <el-input
                  v-model="inputForm2.operId"
                  placeholder="请填写法定代表人ID"
                ></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="法定代表人名称" prop="operName" :rules="[]">
                <el-input
                  v-model="inputForm2.operName"
                  placeholder="请填写法定代表人名称"
                ></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="成立日期" prop="startDate" :rules="[]">
                <el-date-picker
                  style="width: 100%"
                  v-model="inputForm2.startDate"
                  type="datetime"
                  value-format="yyyy-MM-dd HH:mm:ss"
                  placeholder="选择日期时间"
                >
                </el-date-picker>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="吊销日期" prop="endDate" :rules="[]">
                <el-date-picker
                  style="width: 100%"
                  v-model="inputForm2.endDate"
                  type="datetime"
                  value-format="yyyy-MM-dd HH:mm:ss"
                  placeholder="选择日期时间"
                >
                </el-date-picker>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="登记状态" prop="status" :rules="[]">
                <el-input
                  v-model="inputForm2.status"
                  placeholder="请填写登记状态"
                ></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="省份" prop="province" :rules="[]">
                <el-input
                  v-model="inputForm2.province"
                  placeholder="请填写省份"
                ></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="更新日期" prop="updatedDate" :rules="[]">
                <el-date-picker
                  style="width: 100%"
                  v-model="inputForm2.updatedDate"
                  type="datetime"
                  value-format="yyyy-MM-dd HH:mm:ss"
                  placeholder="选择日期时间"
                >
                </el-date-picker>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item
                label="统一社会性用代码"
                prop="creditCode"
                :rules="[]"
              >
                <el-input
                  v-model="inputForm2.creditCode"
                  placeholder="请填写统一社会性用代码"
                ></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="注册资本" prop="registCapi" :rules="[]">
                <el-input
                  v-model="inputForm2.registCapi"
                  placeholder="请填写注册资本"
                ></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="企业类型" prop="econKind" :rules="[]">
                <el-input
                  v-model="inputForm2.econKind"
                  placeholder="请填写企业类型"
                ></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="注册地址" prop="address" :rules="[]">
                <el-input
                  v-model="inputForm2.address"
                  placeholder="请填写注册地址"
                ></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="经营范围" prop="scope" :rules="[]">
                <el-input
                  v-model="inputForm2.scope"
                  placeholder="请填写经营范围"
                ></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="营业期限始" prop="termStart" :rules="[]">
                <el-input
                  v-model="inputForm2.termStart"
                  placeholder="请填写营业期限始"
                ></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="营业期限至" prop="teamEnd" :rules="[]">
                <el-input
                  v-model="inputForm2.teamEnd"
                  placeholder="请填写营业期限至"
                ></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="核准日期" prop="checkDate" :rules="[]">
                <el-input
                  v-model="inputForm2.checkDate"
                  placeholder="请填写核准日期"
                ></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="组织机构代码" prop="orgNo" :rules="[]">
                <el-input
                  v-model="inputForm2.orgNo"
                  placeholder="请填写组织机构代码"
                ></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="是否上市" prop="isOnStock" :rules="[]">
                <el-select
                  v-model="inputForm2.isOnStock"
                  placeholder="请选择上市状态"
                  style="width: 100%"
                >
                  <el-option label="未上市" value="0"></el-option>
                  <el-option label="已上市" value="1"></el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="股票代码" prop="stockNumber" :rules="[]">
                <el-input
                  v-model="inputForm2.stockNumber"
                  placeholder="请填写股票代码"
                ></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="24">
              <el-form-item label="企业Logo地址" prop="imageUrl" :rules="[]">
                <el-upload
                  ref="imageUrl"
                  v-if="visible"
                  list-type="picture-card"
                  :action="`${this.$http.BASE_URL}/sys/file/webupload/upload?uploadPath=/p_enterprisebusiness/pEnterpriseBusiness`"
                  :headers="{ token: $cookie.get('token') }"
                  :on-preview="
                    (file, fileList) => {
                      showImg(inputForm.imageUrl);
                    }
                  "
                  :on-success="
                    (response, file, fileList) => {
                      inputForm2.imageUrl = fileList
                        .map(
                          (item) =>
                            (item.response && item.response.url) || item.url
                        )
                        .join('|');
                    }
                  "
                  :on-remove="
                    (file, fileList) => {
                      $http
                        .post(
                          `/sys/file/webupload/deleteByUrl?url=${
                            (file.response && file.response.url) || file.url
                          }`
                        )
                        .then(({ data }) => {
                          $message.success(data.msg);
                        });
                      inputForm2.imageUrl = fileList
                        .map((item) => item.url)
                        .join('|');
                    }
                  "
                  :before-remove="
                    (file, fileList) => {
                      return $confirm(`确定移除 ${file.name}？`);
                    }
                  "
                  multiple
                  :limit="1"
                  :on-exceed="
                    (files, fileList) => {
                      $message.warning(
                        `当前限制选择 1 个文件，本次选择了 ${
                          files.length
                        } 个文件，共选择了 ${
                          files.length + fileList.length
                        } 个文件`
                      );
                    }
                  "
                  :file-list="imageUrlArra"
                >
                  <i class="el-icon-plus"></i>
                </el-upload>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="企业性质" prop="entType" :rules="[]">
                <el-radio-group v-model="inputForm2.entType">
                  <el-radio
                    v-for="item in $dictUtils.getDictList('')"
                    :label="item.value"
                    :key="item.id"
                    >{{ item.label }}</el-radio
                  >
                </el-radio-group>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="实缴资本" prop="recCap" :rules="[]">
                <el-input
                  v-model="inputForm2.recCap"
                  placeholder="请填写实缴资本"
                ></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="行政区划代码" prop="areaCode" :rules="[]">
                <el-input
                  v-model="inputForm2.areaCode"
                  placeholder="请填写行政区划代码"
                ></el-input>
              </el-form-item>
            </el-col>
          </el-row>
        </el-form>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button v-if="active !== 1" style="margin-top: 12px" @click="upper"
          >上一步</el-button
        >
        <el-button
          v-if="inputForm.auditStatus == 0 && active == 3"
          style="margin-top: 12px"
          @click="audit(inputForm.id, 1, inputForm.user.id)"
          >通过</el-button
        >
        <el-button
          v-if="inputForm.auditStatus == 0 && active == 3"
          style="margin-top: 12px"
          @click="refuse(inputForm.id, 2, inputForm.user.id)"
          >拒绝</el-button
        >
        <el-button v-if="active !== 3" style="margin-top: 12px" @click="next"
          >下一步</el-button
        >
        <el-button @click="visible = false">关闭</el-button>
        <el-button
          type="primary"
          v-if="method != 'view'"
          @click="doSubmit()"
          v-noMoreClick
          >确定</el-button
        >
      </span>
    </el-dialog>
  </div>
</template>

<script>
import GridSelect from "@/components/gridSelect";
export default {
  data() {
    return {
      title: "",
      method: "",
      visible: false,
      loading: false,
      legalPersonIdCardPortraitArra: [],
      legalPersonIdCardNationalEmblemFaceArra: [],
      handledByIdCardPortraitArra: [],
      handledByIdCardNationalEmblemFaceArra: [],
      businessLicenseArra: [],
      active: 1,
      valueList: [],
      inputForm: {
        id: "",
        user: {
          id: "",
        },
        enterpriseFullName: "",
        unifiedSocialCreditCode: "",
        officeArea: "",
        officeAddress: "",
        longitude: "",
        latitude: "",
        companySize: "",
        legalPersonName: "",
        attentionLine: "",
        operatorsTelephone: "",
        affiliationIndustry: "",
        businessLicense: "",
        legalPersonIdCardPortrait: "",
        legalPersonIdCardNationalEmblemFace: "",
        handledByIdCardPortrait: "",
        handledByIdCardNationalEmblemFace: "",
        auditStatus: "",
        reasonRejection: "",
        auditTime: "",
        remarks: "",
      },
      inputForm2: {
        id: "",
        enterpriseCertification: {
          id: "",
        },
        keyNo: "",
        name: "",
        no: "",
        belongOrg: "",
        operId: "",
        operName: "",
        startDate: "",
        endDate: "",
        status: "",
        province: "",
        updatedDate: "",
        creditCode: "",
        registCapi: "",
        econKind: "",
        address: "",
        scope: "",
        termStart: "",
        teamEnd: "",
        checkDate: "",
        orgNo: "",
        isOnStock: "",
        stockNumber: "",
        imageUrl: "",
        entType: "",
        recCap: "",
        areaCode: "",
        remarks: "",
      },
      markersArray: [],
      imageUrlArra: [],
    };
  },
  components: {
    GridSelect,
  },
  activated() {
    this.getvalueList();
  },
  methods: {
    showImg(imgStrList) {
      var imgList = imgStrList.split("|");
      this.$hevueImgPreview({
        multiple: true,
        nowImgIndex: 0,
        imgList: imgList,
      });
    },
    // 获取数据列表
    getvalueList() {
      this.$http({
        url: "/valueinfo/tValueInfo/list",
        method: "get",
        params: {
          pageNo: 1,
          pageSize: 999,
          orderBy: this.orderBy,
          type: 7,
        },
      }).then(({ data }) => {
        if (data && data.success) {
          this.valueList = data.page.list;
        }
      });
    },
    init(method, id) {
      this.active = 1;
      this.method = method;
      this.inputForm.id = id;
      if (method === "add") {
        this.title = `新建企业认证`;
      } else if (method === "edit") {
        this.title = "修改企业认证";
      } else if (method === "view") {
        this.title = "查看企业认证";
      }
      this.legalPersonIdCardPortraitArra = [];
      this.businessLicenseArra = [];
      this.legalPersonIdCardNationalEmblemFaceArra = [];
      this.handledByIdCardPortraitArra = [];
      this.handledByIdCardNationalEmblemFaceArra = [];
      this.visible = true;
      this.loading = false;
      this.$nextTick(() => {
        this.$refs.inputForm.resetFields();
        this.$refs.inputForm2.resetFields();
        if (method === "edit" || method === "view") {
          // 修改或者查看
          this.loading = true;
          this.$http({
            url: `/p_enterprisecertification/pEnterpriseCertification/queryById?id=${this.inputForm.id}`,
            method: "get",
          }).then(({ data }) => {
            this.inputForm = this.recover(
              this.inputForm,
              data.pEnterpriseCertification
            );
            this.inputForm.businessLicense.split("|").forEach((item) => {
              if (item.trim().length > 0) {
                this.businessLicenseArra.push({
                  name: decodeURIComponent(
                    item.substring(item.lastIndexOf("/") + 1)
                  ),
                  url: item,
                });
              }
            });
            this.inputForm.legalPersonIdCardPortrait
              .split("|")
              .forEach((item) => {
                if (item.trim().length > 0) {
                  this.legalPersonIdCardPortraitArra.push({
                    name: decodeURIComponent(
                      item.substring(item.lastIndexOf("/") + 1)
                    ),
                    url: item,
                  });
                }
              });
            this.inputForm.legalPersonIdCardNationalEmblemFace
              .split("|")
              .forEach((item) => {
                if (item.trim().length > 0) {
                  this.legalPersonIdCardNationalEmblemFaceArra.push({
                    name: decodeURIComponent(
                      item.substring(item.lastIndexOf("/") + 1)
                    ),
                    url: item,
                  });
                }
              });
            this.inputForm.handledByIdCardPortrait
              .split("|")
              .forEach((item) => {
                if (item.trim().length > 0) {
                  this.handledByIdCardPortraitArra.push({
                    name: decodeURIComponent(
                      item.substring(item.lastIndexOf("/") + 1)
                    ),
                    url: item,
                  });
                }
              });
            this.inputForm.handledByIdCardNationalEmblemFace
              .split("|")
              .forEach((item) => {
                if (item.trim().length > 0) {
                  this.handledByIdCardNationalEmblemFaceArra.push({
                    name: decodeURIComponent(
                      item.substring(item.lastIndexOf("/") + 1)
                    ),
                    url: item,
                  });
                }
              });
            this.initMap(this.inputForm.longitude, this.inputForm.latitude);

            this.loading = false;
          });
        } else {
          this.initMap();
        }
      });
    },
    next() {
      this.active++;
      if (this.active == 3) {
        this.$http({
          url: `/p_enterprisecertification/pEnterpriseCertification/getBusinessAdministration?enterpriseCertificationId=${this.inputForm.id}&creditCode=${this.inputForm.unifiedSocialCreditCode}&auditStatus=${this.inputForm.auditStatus}`,
          method: "get",
        }).then(({ data }) => {
          if (data.success) {
            data.pEnterpriseBusiness.remarks = data.message;
            this.inputForm2 = this.recover(
              this.inputForm2,
              data.pEnterpriseBusiness
            );
            this.inputForm2.imageUrl.split("|").forEach((item) => {
              if (item.trim().length > 0) {
                this.imageUrlArra.push({
                  name: decodeURIComponent(
                    item.substring(item.lastIndexOf("/") + 1)
                  ),
                  url: item,
                });
              }
            });
            this.$message.success(data.message);
          }
        });
      }
    },
    initMap(longitude, latitude) {
      var that = this;
      let address = "";
      let lat = "36.752508224779746";
      let logt = "119.97121810913086";
      if (!longitude) {
        let lat = latitude;
        let logt = longitude;
      }
      if (this.inputForm.latitude === "") {
        var center = new qq.maps.LatLng(lat, logt);
      } else {
        var center = new qq.maps.LatLng(
          this.inputForm.latitude,
          this.inputForm.longitude
        );
      }
      var map = new qq.maps.Map(document.getElementById("containepic"), {
        center: center,
        zoom: 13,
        disableDefaultUI: true,
      });
      var marker = new qq.maps.Marker({
        position: center,
        map: map,
      });
      that.markersArray.push(marker);
      var infoWin = new qq.maps.InfoWindow({
        map: map,
      }); //此处是点击地图后生成的地标名称
      var geocoder = new qq.maps.Geocoder({
        complete: function (res) {
          that.deleteOverlays();
          map.setCenter(res.detail.location);
          var marker = new qq.maps.Marker({
            map: map,
            position: res.detail.location,
          });
          that.markersArray.push(marker);
        },
      });

      qq.maps.event.addListener(map, "click", function (event) {
        that.deleteOverlays();
        // this.latitude = event.latLng.getLat();
        // this.longiistude = event.latLng.getLng();
        // console.log(this.longiistude, this.latitude);
        that.inputForm.longitude = event.latLng.getLng();
        that.inputForm.latitude = event.latLng.getLat();
        var position = new qq.maps.LatLng(
          that.inputForm.latitude,
          that.inputForm.longitude
        );
        var marker = new qq.maps.Marker({
          map: map,
          position: position,
        });
        that.markersArray.push(marker);
      });
      document
        .getElementById("handleinput")
        .addEventListener("blur", function () {
          geocoder.getLocation(that.inputForm.officeAddress);
        });
    },
    deleteOverlays() {
      if (this.markersArray) {
        for (var i in this.markersArray) {
          this.markersArray[i].setMap(null);
        }
        this.markersArray.length = 0;
      }
    },
    upper() {
      this.active--;
    },
    audit(id, status, userId) {
      this.$confirm(`确定当前操作?`, "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      }).then(() => {
        this.loading = true;
        this.$http({
          url: "/p_enterprisecertification/pEnterpriseCertification/audit",
          method: "post",
          params: { id: id, auditStatus: status, userId: userId },
        }).then(({ data }) => {
          if (data && data.success) {
            this.visible = false;
            this.$message.success(data.msg);
            this.$emit("refreshDataList");
          }
          if (!data.success) {
            this.visible = false;
            this.$message.success(data.msg);
            this.$emit("refreshDataList");
          }
          this.loading = false;
        });
      });
    },
    //拒绝审核
    refuse(id, status, userId) {
      this.$prompt("请输入拒绝原因", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
      })
        .then(({ value }) => {
          if (!value) {
            this.$message.error("请输入拒绝原因");
            return false;
          }
          this.loading = true;
          console.log(id, status, userId, 1111);
          this.$http({
            url: "/p_enterprisecertification/pEnterpriseCertification/audit",
            method: "post",
            params: {
              id: id,
              auditStatus: status,
              refuseReason: value,
              userId: userId,
            },
          }).then(({ data }) => {
            if (data && data.success) {
              this.visible = false;
              this.$message.success(data.msg);
              this.$emit("refreshDataList");
            }
            if (!data.success) {
              this.visible = false;
              this.$message.success(data.msg);
              this.$emit("refreshDataList");
            }
            this.loading = false;
          });
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "取消输入",
          });
        });
    },
    // 表单提交
    doSubmit() {
      this.$refs["inputForm"].validate((valid) => {
        if (valid) {
          this.loading = true;
          this.$http({
            url: `/p_enterprisecertification/pEnterpriseCertification/save`,
            method: "post",
            data: this.inputForm,
          }).then(({ data }) => {
            this.loading = false;
            if (data && data.success) {
              this.visible = false;
              this.$message.success(data.msg);
              this.$emit("refreshDataList");
            }
          });
        }
      });
    },
  },
};
</script>
<style lang="less">
#containepic {
  width: 750px;
  height: 500px;
}
</style>
